libxc: Exchange a page for PV guest
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 1 Jun 2009 13:15:48 +0000 (14:15 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 1 Jun 2009 13:15:48 +0000 (14:15 +0100)
commitd06a984487230b6e078e30f2cea26b3baf937efc
tree97679128014fe5f84e3c740345d18b43bf301984
parent1472f8177f8ec6d81b471d678cf22e04c36e1a2a
libxc: Exchange a page for PV guest

This patch support exchange a page for a suspended PV guest from user
space.

The basic idea to offline a page is:
1) mark a page offline pending
2) If the page is owned by a HVM domain, user have to live migrate it.
    In future, with stub-domain support, we can also exchange the page
    without migration.
3) If the page is owned by a PV domain, we will try to exchange the
offline pending page to a new one and free the old page.

This patch achieves item 3.

The method to exchange the offline pending page for PV domain is:

1) Suspend the guest.
2) If the page is being granted out, return with offline pending.
3) Get a copy for the content
4) Scan all page table page to see if any reference to the offending
page, if yes, make the entry to be non-present to reduce the reference
count.
5) After update all page tables, user space tools will try to exchange
the old page. If the new mfn has no reference anymore (i.e.
count_info & count_mask =3D 1), the exchange will allocate a new page,
update the m2p and return success, otherwise it will return fail.
6) If step 5 is success, user space tools will update the content of
the new page  change the p2m table, and change all entries scaned in
step 4 to point to new entry.
if step failed, it will try to undo step 4 to revert page table.
7) Resume the guest.

Please refer to thread in
http://www.mailinglistarchive.com/xen-devel@lists.xensource.com/msg63084.html
for more information.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>
tools/libxc/xc_offline_page.c
tools/libxc/xc_suspend.c
tools/libxc/xenguest.h